<?php

require_once '../config.php';

require_once '../includes/functions.php';

if (!isLoggedIn()) {

    redirect('../login.php');

}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $apps = getApps();

    foreach ($apps as &$app) {

        if ($app['id'] === $_POST['id']) {

            $app['name'] = $_POST['name'];

            $app['icon'] = $_POST['icon'];

            $app['download_url'] = $_POST['download_url'];

            $app['description'] = $_POST['description'];

            $app['update_content'] = $_POST['update_content'];

            $app['version'] = $_POST['version'];

            break;

        }

    }

    

    saveApps($apps);

    redirect('../admin.php');

} else {

    redirect('../admin.php');

}

?>